#pragma once
#include "IView.h"
namespace UILib
{
    using namespace UIBase;
    class CDrawView : public IView
    {
    public:
        CDrawView(void);
        CDrawView(const PUIRect pRect, const UINT uID = -1, ViewListener* pListener = NULL );

        virtual ~CDrawView(void);

        virtual wstring GetClass(){ return L"DrawView"; };

        virtual void SetTipsListener( TipsListenser* pTipsListener );

        virtual void SetTips( wstring wszTips, bool bShow = true );
        virtual wstring GetTips() const { return wszTips_; };
        virtual bool IsTipsEnable() const { return bShowTips_; };

        virtual void SetID( const UINT uID );
        virtual UINT GetID() const { return uID_; };

        virtual void SetPosition( const POINT pt );
        virtual void SetSize( const SIZE sz );

        virtual void SetRect( const PUIRect pRect );
        virtual PUIRect GetRect() const { return (PUIRect)(&UIRect_); };
        virtual void GetRECT( RECT& rc );

        virtual void SetVisible(const bool bVisible);
        virtual bool IsVisible() const { return bVisible_; };

        virtual void SetEnable(const bool bEnable = true);
        virtual bool IsEnable() const { return bEnable_; };

        virtual void SetCapture( bool bCapture = false );

        virtual void SetListener(ViewListener* pListener);

        virtual void SetFocus();
        virtual bool IsFocused(){ return bFocused_; };

        virtual void HandleMessage( UINT uMsg, WPARAM wParam, LPARAM lParam, HWND hWnd, BOOL& bHandled );
        virtual void DrawElement( const HDC hDC, const RECT &rcPaint ){ bNeedInvalidate_ = false; };

        Elem_Status GetStatus() const { return eStatus_; };

        virtual void ForceInvalidate( const bool bForce = true ) { bNeedInvalidate_ = bForce; };
        virtual bool NeedInvalidata() const { return bNeedInvalidate_; };
        virtual bool NeedInvalidata(RECT& rcReDraw);

        virtual void Layout( const RECT rcClient ){ bNeedInvalidate_ = true; };
    protected:
        static bool HitCursor(DWORD dwPT, RECT& rc );
        static bool HitCursor(POINT ptMouse, RECT& rc );
        static bool HitDraw( const RECT &rcPaint, const RECT& rc );

        bool IsLBDown() const { return bLBDown_; };
    protected:
        ViewListener*   pListener_;
        Elem_Status     eStatus_;
        bool            bLBDown_;

        bool            bNeedInvalidate_;

        TipsListenser*  pTipsListenser_;

        bool            bFocused_;
    private:
        UINT uID_;
        bool bVisible_;
        bool bEnable_;
        bool bCapture_;

        UIRect UIRect_;

        bool bShowTips_;
        wstring wszTips_;
    };
}
